{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑赛事</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">赛事名称：</label>
                            <div class="layui-input-block">
                                <input type="text" name="match_title" lay-verify="required" class="layui-input" placeholder="赛事名称" value="{$match.match_title}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">缩略图：</label>
                            <input type="hidden" name="match_image" id="lay-img" lay-verify="image">
                            <div class="layui-input-block">
                                <div id="lay-upload">上传图片</div>
                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                    预览图：
                                    <div class="layui-upload-list" id="lay-list">
                                        <img class="layui-append-img" src="{$match.match_image}" onerror="this.src='/static/admin/images/no_img.jpg'">
                                    </div>
                                </blockquote>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">举办国家：</label>
                            <div class="layui-input-block">
                                <input type="text" name="match_country_name" lay-verify="required" class="layui-input" placeholder="举办国家" value="{$match.match_country_name}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">赛事省：</label>
                            <div class="layui-input-block">
                                <select name="match_sheng" lay-search="" id="province"  lay-filter="province">
                                    <option value="">---- 请选择省 ----</option>
                                    {foreach name="province" item="vo"}
                                    <option value="{$vo.district_id}" {$vo.district_id == $match.match_sheng ? 'selected' : ''}>{$vo.district}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">赛事市：</label>
                            <div class="layui-input-block">
                                <select name="match_shi" lay-search=""  id="city"  lay-filter="city">
                                    <option value="">---- 请选择市 ----</option>
                                    {foreach name='city' item='vo1'}
                                    <option value="{$vo1.district_id}" {$vo1.district_id == $match.match_shi ? 'selected' : ''}>{$vo1.district}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">赛事区：</label>
                            <div class="layui-input-block">
                                <select name="match_qu" lay-search=""  id="district"  lay-filter="district">
                                    <option value="">---- 请选择区 ----</option>
                                    {foreach name='district' item='vo2'}
                                    <option value="{$vo2.district_id}" {$vo2.district_id == $match.match_qu ? 'selected' : ''}>{$vo2.district}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8" style="margin-top:50px">
                            <label class="layui-form-label">赛事地址:</label>
                            <div class="layui-input-block">
                                <div id="container" style='width:90%;height:400px;z-index: 100;'></div>
                                <div id="myPageTop" style="margin-left: 150px;margin-top:10px;z-index:1000" >
                                    <table>
                                        <tr>
                                            <td>
                                                <label>请输入搜索内容</label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <input id="tipinput" class="dingwei" style="position: absolute;top: 0;right: -120px" placeholder="请输入地址"/>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">定位的地址:</label>
                            <div class="layui-input-block">
                                <table style="border-collapse:separate; border-spacing:5px;">
                                    <tr>
                                        <td>
                                            <input type="text" name="match_addr" class="match_addr" style="height:30px;width:500px" placeholder="详情地址" value="{$match.match_addr}"/>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="text" readonly name="match_lon" class="match_lon" style="height:30px" placeholder="经度" value="{$match.match_lon}"/>
                                        </td>
                                        <td>
                                            <input type="text" readonly name="match_lat" class="match_lat" style="margin-left:-250px;height:30px" placeholder="纬度" value="{$match.match_lat}"/>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">报到省：</label>
                            <div class="layui-input-block">
                                <select name="match_apply_sheng" lay-search="" id="provinceB"  lay-filter="provinceB">
                                    <option value="">---- 请选择省 ----</option>
                                    {foreach name="province" item="voo"}
                                    <option value="{$voo.district_id}" {$voo.district_id == $match.match_apply_sheng ? 'selected' : ''}>{$voo.district}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">报到市：</label>
                            <div class="layui-input-block">
                                <select name="match_apply_shi" lay-search=""  id="cityB"  lay-filter="cityB">
                                    <option value="">---- 请选择市 ----</option>
                                    {foreach name="cityA" item="voo1"}
                                    <option value="{$voo1.district_id}" {$voo1.district_id == $match.match_apply_shi ? 'selected' : ''}>{$voo1.district}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">报到区：</label>
                            <div class="layui-input-block">
                                <select name="match_apply_qu" lay-search=""  id="districtB"  lay-filter="districtB">
                                    <option value="">---- 请选择区 ----</option>
                                    {foreach name="districtA" item="voo2"}
                                    <option value="{$voo2.district_id}" {$voo2.district_id == $match.match_apply_qu ? 'selected' : ''}>{$voo2.district}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8" style="margin-top:50px">
                            <label class="layui-form-label">报到地址:</label>
                            <div class="layui-input-block">
                                <div id="container1" style='width:90%;height:400px;z-index: 100;'></div>
                                <div id="myPageTop1" style="margin-left: 150px;margin-top:10px;z-index:1000" >
                                    <table>
                                        <tr>
                                            <td>
                                                <label>请输入搜索内容</label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <input id="tipinput1" class="dingwei" style="position: absolute;top: 0;right: -120px" placeholder="请输入地址"/>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">定位的地址:</label>
                            <div class="layui-input-block">
                                <table style="border-collapse:separate; border-spacing:5px;">
                                    <tr>
                                        <td>
                                            <input type="text" name="match_apply_addr" class="match_apply_addr" style="height:30px;width:500px" placeholder="详情地址" value="{$match.match_apply_addr}"/>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="text" readonly name="match_apply_lon" class="match_apply_lon" style="height:30px" placeholder="经度" value="{$match.match_apply_lon}"/>
                                        </td>
                                        <td>
                                            <input type="text" readonly name="match_apply_lat" class="match_apply_lat" style="margin-left:-250px;height:30px" placeholder="纬度" value="{$match.match_apply_lat}"/>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">赛事开始时间：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="match_start_time" lay-verify="required" placeholder="赛事开始时间" class="layui-input test-item" value="{$match.match_start_time}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">赛事结束时间：</label>
                            <div class="layui-input-inline">
                                <input type="text"  name="match_end_time" lay-verify="required" placeholder="赛事结束时间" class="layui-input test-item" value="{$match.match_end_time}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">赛事报名开始时间：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="match_apply_start_time" lay-verify="required" placeholder="赛事报名开始时间" class="layui-input test-item" value="{$match.match_apply_start_time}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">赛事报名结束时间：</label>
                            <div class="layui-input-inline">
                                <input type="text"  name="match_apply_end_time" lay-verify="required" placeholder="赛事报名结束时间" class="layui-input test-item" value="{$match.match_apply_end_time}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">组委会电话：</label>
                            <div class="layui-input-block">
                                <input type="text" name="match_committee_phone" lay-verify="required" class="layui-input" placeholder="组委会电话" value="{$match.match_committee_phone}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">赛道数：</label>
                            <div class="layui-input-block">
                                <select name="match_saidao_num">
                                    <option value="4" {$match.match_saidao_num == 4 ? 'selected' : ''}>4</option>
                                    <option value="6" {$match.match_saidao_num == 6 ? 'selected' : ''}>6</option>
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">修改船员信息截止时间：</label>
                            <div class="layui-input-inline">
                                <input type="text"  name="match_stop_time" lay-verify="required" placeholder="修改船员信息截止时间" class="layui-input test-item" value="{$match.match_stop_time}">
                            </div>
                        </div>

                        <input type="hidden" value="{$match_id}" name="match_id">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=1e0d12c4fc7710d9c326e672ac6f26c2&plugin=AMap.Autocomplete,AMap.PlaceSearch,AMap.Geocode"></script>
<script type="text/javascript">
    var map = new AMap.Map("container", {
        resizeEnable: true
    });
    var autoOptions = {
        input: "tipinput"
    };
    var auto = new AMap.Autocomplete(autoOptions);
    var placeSearch = new AMap.PlaceSearch({
        map: map
    });
    AMap.event.addListener(auto, "select", select);
    function select(e) {
        placeSearch.setCity(e.poi.adcode);
        placeSearch.search(e.poi.name);
        var lng = e.poi.location.lng;   //获取经度
        var lat = e.poi.location.lat;   //获取纬度
        var address = e.poi.district+e.poi.name;   //获取纬度
        $('input[name=match_addr]').val(address);
        $('input[name=match_lon]').val(lng);
        $('input[name=match_lat]').val(lat);
    }
    AMap.event.addListener(placeSearch, "markerClick", addasd)

    function addasd(e) {
        $('input[name=match_addr]').val(e.data.pname+e.data.cityname+e.data.adname+e.data.name);
        $('input[name=match_lon]').val(e.data.location.lng);
        $('input[name=match_lat]').val(e.data.location.lat);
    }
</script>

<!--报到地址-->
<script type="text/javascript">

    var map1 = new AMap.Map("container1", {
        resizeEnable: true
    });

    var autoOptions1 = {
        input: "tipinput1"
    };

    var auto1 = new AMap.Autocomplete(autoOptions1);
    var placeSearch1 = new AMap.PlaceSearch({
        map: map1
    });
    AMap.event.addListener(auto1, "select", select1);
    function select1(e) {
        placeSearch1.setCity(e.poi.adcode);
        placeSearch1.search(e.poi.name);
        var lng = e.poi.location.lng;   //获取经度
        var lat = e.poi.location.lat;   //获取纬度
        var address = e.poi.district+e.poi.name;   //获取纬度
        $('input[name=match_apply_addr]').val(address);
        $('input[name=match_apply_lon]').val(lng);
        $('input[name=match_apply_lat]').val(lat);
    }
    AMap.event.addListener(placeSearch1, "markerClick", addasd1);

    function addasd1(e) {
        $('input[name=match_apply_addr]').val(e.data.pname+e.data.cityname+e.data.adname+e.data.name);
        $('input[name=match_apply_lon]').val(e.data.location.lng);
        $('input[name=match_apply_lat]').val(e.data.location.lat);
    }
</script>
<script>
    //    var editor = wk.wang({elem:'#LAY_editor'});
    wk.uploadImg({size:5,type:'png,jpg,jpeg',url:"{:url('Upload/upload')}",domain:""});
    layui.use(['form','upload','layedit','laydate'], function() {
        var form = layui.form;
//        form.verify({
//            editor:function(value,item){
//                if(editor.txt.html() == '<p><br></p>'){
//                    return '请填写内容';
//                }
//            }
//        });
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('rowingEdit')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('Match/index')}")
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            });

        });
        var laydate = layui.laydate;
        //同时绑定多个
        lay('.test-item').each(function(){
            laydate.render({
                elem: this
                ,format:'yyyy-MM-dd HH:mm:ss'
                ,type:'datetime'
                ,trigger: 'click'
            });
        });
    });
</script>

</body>
</html>
